package com.taobaolite.user.admin;

import com.taobaolite.user.User;
import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;

import javax.persistence.*;

@Entity
@Table
public class Admin {
    @Id
    @Column(name = "adminId")
    private Long adminId;

    @OneToOne(cascade = CascadeType.ALL)
    @OnDelete(action = OnDeleteAction.CASCADE)
    @MapsId
    @JoinColumn(name = "adminId")
    private User user;

    public Admin() {}

    public Admin(User user) {
        this.user = user;
    }

    public void setAdminId(Long adminId) {
        this.adminId = adminId;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public Long getAdminId() {
        return adminId;
    }

    public User getUser() {
        return user;
    }
}
